/*
 * @lc app=leetcode.cn id=1640 lang=javascript
 *
 * [1640] 能否连接形成数组
 */

// @lc code=start
/**
 * @param {number[]} arr
 * @param {number[][]} pieces
 * @return {boolean}
 */
var canFormArray = function (arr, pieces) {
  if (pieces.length === 1) {
    return arr.toString() === pieces[0].toString();
  }
  const str = arr.toString();
  return pieces.every(piece => {
    return str.includes(',' + piece.toString()) || str.includes(piece.toString() + ',');
  });
};
// @lc code=end

